<template v-loading="loading">
  <el-table :data="tableDataChild" :show-header="false">
    <el-table-column prop="date" label="" width="48" >
        
    </el-table-column>
    <el-table-column prop="date" label="" width="130" >
        
    </el-table-column>
    <el-table-column label="服务名称" prop="sServiceName"></el-table-column>
    <el-table-column label="收费金额（元）" prop="sMoney">
        <template scope="scope">
            {{!scope.row.sMoney ? '0' : scope.row.sMoney}}
        </template>
    </el-table-column>
    <el-table-column label="分成比例">
        <template scope="scope">
            {{!scope.row.sDividedPercentage ? "未设置" : scope.row.sDividedPercentage + '%'}}
        </template>
    </el-table-column>
    <el-table-column label="收费方式">
        <template scope="scope">
        <!-- 1月收  2按学期收 3永久型 -->
            {{scope.row.sPayTypeNew == '1' ? '月收' :  scope.row.sPayTypeNew  == '2' ? '年收' : '--' }}
        </template>
    </el-table-column>
    <el-table-column label="是否开通">
        <template scope="scope">
        <!-- 0:未开通 1审核中 2已开通 3审核未通过 -->
        {{scope.row.sStatus == '0' ? '未开通' : scope.row.sStatus == '1' ? '审核中' : scope.row.sStatus == '2' ? '已开通' : scope.row.sStatus == '3' ? '审核未通过' :'未开通'}}
    </template>
    </el-table-column>
    <el-table-column label="收费开始时间" prop="sPayStartTime">
        <template scope="scope">
            {{!scope.row.sPayStartTime ? '未设置' : scope.row.sPayStartTime}}
        </template>
    </el-table-column>
    <el-table-column label="申请开通时间" prop="sCreateTime">
        <template scope="scope">
            {{!scope.row.sCreateTime ? '未开通' : scope.row.sCreateTime}}
        </template>
    </el-table-column>
    <el-table-column label="操作">
        <template scope="scope">
        <el-button v-if="scope.row.sStatus == '0' || !scope.row.sStatus" type="text" class="btn-success" @click="openService(scope.row)" >申请开通</el-button>
        <el-button v-else-if="scope.row.sStatus == '3'" type="text" class="btn-success" @click="afreshService(scope.row)" >重新开通</el-button>
        <el-button v-else-if="scope.row.sStatus == '2'" type="text" class="btn-success" @click="modService(scope.row)" >修改</el-button>
        <el-button v-else class="btn-success" type="text" @click="getService(scope.row)" >查看</el-button>
        </template>  
    </el-table-column>  
    </el-table>
</template>
<script>
import { listServiceInfoById } from 'api/serviceManage';
export default {
    data() {
        return {
            loading: false,
            tableDataChild: [] // 内table
        };
    },
    props: {
        scope: Object // $index/row/store  你可以看scope 这个对象，这个页面有很多简化的
    },
    created() {
        this.btnChild(this.scope)
    },
    methods: {
        btnChild(val) {
            if (val.row.fSchoolId) {
                this.loading = true;
                listServiceInfoById(val.row.fSchoolId).then(data => {
                    this.loading = false;
                    if (data.data.content) {
                        this.tableDataChild = data.data.content;
                    }
                }).catch(Error => {
                    this.loading = false;
                    this.$message.error(Error)
                })
            } else {
                this.tableDataChild = [];
            }
        },
        // 申请开通
        openService(val) {
            this.$router.push({
                path: `newService/1/obj/true/${val.sSchoolName}/${val.sServiceName}/${val.fSchoolId}/${val.fServiceId}`
                // path: `/serviceContent/newService/1/${true}/${val.sSchoolName}/${val.sServiceName}/${val.fSchoolId}`

                // 三个参数，sSchoolName:学校名称  && sServiceName:服务名称 && fSchoolId
            });
        },
    // 重新开通
        afreshService(val) {
            this.$router.push({
                path: `newService/2/${val.pId}/${false}`
                // params: { state: '2', obj: val.pId, add: false }
            });
        },
    // 修改开通
        modService(val) {
            this.$router.push({
                path: `newService/3/${val.pId}/${false}`
                // name: '服务开通',
                // params: { state: '3', obj: val.pId, add: false }
            });
        },

        // 查看开通
        getService(val) {
            this.$router.push({
                path: `/serviceContent/newService/4/${val.pId}/${false}`
                // name: '服务开通',
                // params: { state: '4', obj: val.pId, add: false }
            });
        }
    }
};
</script>
